#include "stdafx.h"
/*
#include "BarcodeDecoderThread.h"
#include "OpenCvWidget.h"

namespace AirCrash {
namespace Calypso {

BarcodeDecoderThread::BarcodeDecoderThread() : QThread(), mInterrupted(false), mCamera(0) {
	qDebug() << "Decoder Version: " << qr_decoder_version();
}

BarcodeDecoderThread::~BarcodeDecoderThread() {
}

void BarcodeDecoderThread::run() {
	if (mCamera != 0) {
		mInterrupted = false;

		QrDecoderHandle decoder = qr_decoder_open();

		while (!mInterrupted) {
			QImage qImg(mCamera->getImage());
			if (qImg.isNull() || qr_decoder_is_busy(decoder)) {
				QThread::usleep(500);
				continue;
			}
			IplImage * image = QImageToIplImage(qImg);
			short stat = qr_decoder_decode_image(decoder, image);

			//QrCodeHeader header;
			//if(qr_decoder_get_header(decoder, &header)) {
				//char * buf = new char[header.byte_size + 1];
				//qr_decoder_get_body(decoder, (unsigned char *)buf, header.byte_size + 1);
				//qDebug() << "Result: " << buf;

				//QString resultString(buf);
				//if (resultString.toInt() != 0) {
				//	emit result(resultString);
				//}
			//}

			free(image->imageData);
			cvReleaseImageHeader(&image);

			QThread::usleep(500);
		}

		qr_decoder_close(decoder);
	}
}
void BarcodeDecoderThread::interrupt() {
	mInterrupted = true;
}

void BarcodeDecoderThread::setCamera(OpenCvWidget * camera) {
	mCamera = camera;
}

}
}
*/
